Skip to content

Add support of ldk-node#307

Open
randomlogin wants to merge 5 commits into
bitcoin-dev-project:mainfrom
randomlogin:add-ldk-support
Open

Add support of ldk-node#307
randomlogin wants to merge 5 commits into
bitcoin-dev-project:mainfrom
randomlogin:add-ldk-support

Conversation

@randomlogin
Copy link
Copy Markdown

This PR adds support of ldk-node to sim-ln.

Closes: #26

As ldk-node is not a daemon, before we start we parse the simulation config file and extract all ldk-nodes, build them and start. For that an additional chain source (bitcoind/esplora/electrum) is needed to start.

Before this PR can be merged, an update of used lighting libraries should be merged, as the current ldk-node has newer versions.

@carlaKC
Copy link
Copy Markdown
Contributor

carlaKC commented Apr 8, 2026

Before this PR can be merged, an update of used lighting libraries should be merged, as the current ldk-node has newer versions.

Feel free to bump this in a preparatory commit in this PR!

Add `LdkNode` as a new `LightningNode` implementation backed by
ldk-server-client over gRPC-over-HTTPS. Supports keysend via
`spontaneous_send`, payment tracking via polling `get_payment_details`,
graph queries, and channel capacity reporting.

Wire up `NodeConnection::Ldk` in sim-cli parsing so ldk-server nodes
can be specified in sim.json alongside LND, CLN, and Eclair nodes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@randomlogin
Copy link
Copy Markdown
Author

Initially I was trying to wire up ldk-node, which is not a daemon and I thought sim-ln could orchestrate ldk-node building, initialization. However it turned out that we want already running and funded nodes with opened channels, so this wasn't an option.

Added support of https://github.com/lightningdevkit/ldk-server, which is a reference daemon implementation with external API, it uses ldk-node internally.

Please note, that ldk-server has not yet been released, therefore a git reference and a revision is used in Cargo.toml

The configuration for ldk-server looks in the following way:

{
  "address": <ip:port or domain:port>,
  "api_key": <hex_encoded_api_key>,
  "cert": <path_to_tls_cert>,
  "network": <bitcoin|testnet|signet|regtest>
}

Please note that currently it's not possible to guess the network via RPC calls, that's why we need to provide it in the config. This might change in future.

@randomlogin randomlogin marked this pull request as ready for review April 22, 2026 13:44
@carlaKC
Copy link
Copy Markdown
Contributor

carlaKC commented Apr 22, 2026

Added support of https://github.com/lightningdevkit/ldk-server, which is a reference daemon implementation with external API, it uses ldk-node internally.
Please note, that ldk-server has not yet been released, therefore a git reference and a revision is used in Cargo.toml

Happy to go with server, I believe a release is coming soon ™️ !

@carlaKC
Copy link
Copy Markdown
Contributor

carlaKC commented Apr 27, 2026

Promise to get to review this week - sorry I've been a bit slow but it's on my list!

Previously we had to specify the network in the config file. Now, as the
network field is added to the get-node-info response we can deduce it
ourselves.
Copy link
Copy Markdown
Contributor

@chuksys chuksys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! I've done a quick initial code/design review. It looks good so far, but I still need to run some local tests. I'll do that ASAP and get back to you with final feedback.

Comment thread simln-lib/src/ldk.rs Outdated
Comment thread simln-lib/src/ldk.rs Outdated
Comment thread simln-lib/src/ldk.rs Outdated
Comment thread simln-lib/src/ldk.rs Outdated
Comment thread simln-lib/src/ldk_server.rs
Comment thread simln-lib/src/lib.rs Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
@randomlogin randomlogin requested a review from chuksys May 11, 2026 12:48
Comment thread simln-lib/src/ldk_server.rs Outdated
};

pub struct LdkNode {
pub struct LdkServer {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To align with the naming conventions of the other impls, let's go with LdkServerNode here & elsewhere. Sorry for the back-and-forth!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed. Force pushed without a new commit.

@randomlogin randomlogin requested a review from chuksys May 11, 2026 22:55
@chuksys
Copy link
Copy Markdown
Contributor

chuksys commented May 12, 2026

Just tested this using the following config:

{
    "nodes": [
      {
        "id": "alice",
        "address": "172.23.48.1:10002",
        "macaroon": "/mnt/c/Users/User/.polar/networks/1/volumes/lnd/alice/data/chain/bitcoin/regtest/admin.macaroon",
        "cert": "/mnt/c/Users/User/.polar/networks/1/volumes/lnd/alice/tls.cert"
      },
      {
        "id": "carol",
        "address": "172.23.48.1:10003",
        "macaroon": "/mnt/c/Users/User/.polar/networks/1/volumes/lnd/carol/data/chain/bitcoin/regtest/admin.macaroon",
        "cert": "/mnt/c/Users/User/.polar/networks/1/volumes/lnd/carol/tls.cert"      
      },
      {
        "address": "https://localhost:3536",
        "api_key": "b91adc35b0d407dab92f5b821d51e343a19497cadd0b7fd518b846c156db6df3",
        "cert": "/tmp/ldk-server/tls.crt"
      }
    ],
    "activity": [
      {
        "source": "alice",
        "destination": "carol",
        "interval_secs": 1,
        "amount_msat": 2000
      },
      {
        "source": "alice",
        "destination": "02df5ad45ae0bfc2b9fef546640ea89cd482274e92b7bb38e1d394822c8368d173",
        "interval_secs": 5,
        "amount_msat": 5000
      }
    ]
}

These are the logs:

sim-ln-test-with-ldk-server

Comment thread sim-cli/src/parsing.rs Outdated
Lnd(lnd::LndConnection),
Cln(cln::ClnConnection),
Eclair(eclair::EclairConnection),
Ldk(ldk_server::LdkServerConnection),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be LdkServer not Ldk.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed

Comment thread sim-cli/src/parsing.rs Outdated
NodeConnection::Lnd(c) => Arc::new(Mutex::new(LndNode::new(c).await?)),
NodeConnection::Cln(c) => Arc::new(Mutex::new(ClnNode::new(c).await?)),
NodeConnection::Eclair(c) => Arc::new(Mutex::new(EclairNode::new(c).await?)),
NodeConnection::Ldk(c) => Arc::new(Mutex::new(LdkServerNode::new(c).await?)),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be LdkServer not Ldk.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed

@randomlogin randomlogin requested a review from chuksys May 12, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Multi-Implementation Support

3 participants